home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 4 / Meeting Pearls Vol. IV (1996)(GTI - Schatztruhe)[!].iso / Pearls / midi / misc / Midi2TeX / src / tp_misc.c < prev    next >
C/C++ Source or Header  |  1994-03-23  |  5KB  |  230 lines

  1. /* Output from p2c, the Pascal-to-C translator */
  2. /* From input file "tp_misc.pas" */
  3.  
  4. #ifdef __TURBOC__
  5. #include <IO.h>
  6. #endif
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. #define TP_MISC_G
  11. #include "tp_misc.h"
  12.  
  13.  
  14. /**********************************************/
  15. unsigned int Power(TheNumber,TheExp)
  16. unsigned int TheNumber;
  17. unsigned int TheExp;
  18. {
  19.   /**********************************************/
  20.   unsigned int tmp;
  21.  
  22.   tmp = 1;
  23.   while (TheExp > 0) {
  24.     tmp *= TheNumber;
  25.     TheExp--;
  26.   }
  27.   return tmp;
  28. }  /* power */
  29.  
  30. #ifdef Doemaar  /* komt ook voor in tp_debug.c */
  31. /********************************************************/
  32. static void WriteDebugInfo(Instring)
  33. Char *Instring;
  34. {
  35.   /********************************************************/
  36.   if (!Debug)
  37.     return;
  38.   switch (DebugOut) {
  39.  
  40.   case SCREEN:
  41.     puts(Instring);
  42.     break;
  43.  
  44.   case DEBFILE:
  45.     fprintf(DebugFile, "%s\n", Instring);
  46.     break;
  47.  
  48.   case PRINT:
  49.     cprintf("%s\n", Instring);
  50.     break;
  51.   }
  52. }
  53. #endif
  54.  
  55. /********************************************************/
  56. Char *I2S(Result, Num)
  57. Char *Result;
  58. long Num;
  59. {
  60.   /********************************************************/
  61.   Char Res[26];
  62.  
  63.   sprintf(Res, "%12ld", Num);
  64.   strcpy(Result, Res);
  65.   return Result;
  66. }
  67.  
  68.  
  69. /********************************************************/
  70. Char *SI2S(Result, Num)
  71. Char *Result;
  72. long Num;
  73. {
  74.   /********************************************************/
  75.   Char Res[26];
  76.  
  77.   sprintf(Res, "%12ld", Num);
  78.   strcpy(Result, Res);
  79.   return Result;
  80. }
  81.  
  82.  
  83. /********************************************************/
  84. Char *B2S(Result, Num)
  85. Char *Result;
  86. long Num;
  87. {
  88.   /********************************************************/
  89.   Char Res[26];
  90.  
  91.   sprintf(Res, "%ld", Num);
  92.   strcpy(Result, Res);
  93.   return Result;
  94. }
  95.  
  96.  
  97. /********************************************************/
  98. Char *LI2S(Result, Num)
  99. Char *Result;
  100. long Num;
  101. {
  102.   /********************************************************/
  103.   Char Res[26];
  104.  
  105.   sprintf(Res, "%12ld", Num);
  106.   strcpy(Result, Res);
  107.   return Result;
  108. }
  109.  
  110.  
  111. /********************************************************/
  112. Char *W2S(Result, Num)
  113. Char *Result;
  114. long Num;
  115. {
  116.   /********************************************************/
  117.   Char Res[26];
  118.  
  119.   sprintf(Res, "%12u", Num);
  120.   strcpy(Result, Res);
  121.   return Result;
  122. }
  123.  
  124.  
  125. /********************************************************/
  126. long TimeDiff(time2, time1)
  127. MeasureTime time2, time1;
  128. {
  129.   /********************************************************/
  130.   long dt;
  131.  
  132.   dt = (time2.Measure - time1.Measure) * PieceContr.TicksPerMeasure;
  133.   dt += time2.MPart - time1.MPart;
  134.   return dt;
  135. }
  136.  
  137.  
  138. /********************************************************/
  139. boolean EqualTime(time2, time1)
  140. MeasureTime time2, time1;
  141. {
  142.   /********************************************************/
  143.   boolean Result;
  144.  
  145.   Result = true;
  146.   if (time2.Measure != time1.Measure)
  147.     Result = false;
  148.   if (time2.MPart != time1.MPart)
  149.     return false;
  150.   return Result;
  151. }
  152.  
  153.  
  154. /*********************************************************************/
  155. Void AddTime(time2, time1, time3)
  156. MeasureTime time2, time1, *time3;
  157. {
  158.   /*********************************************************************/
  159.   long M;
  160.  
  161.   M = PieceContr.TicksPerMeasure * (time1.Measure + time2.Measure) +
  162.       time1.MPart + time2.MPart;
  163.   time3->Measure = M / PieceContr.TicksPerMeasure;
  164.   time3->MPart = M % PieceContr.TicksPerMeasure;
  165. /* p2c: tp_misc.pas, line 124:
  166.  * Note: Using % for possibly-negative arguments [317] */
  167. }
  168.  
  169.  
  170. /*********************************************************************/
  171. void SetTim(time1,M,P)
  172. MeasureTime *time1;
  173. unsigned int M,P;
  174. {
  175.   /*********************************************************************/
  176.   time1->Measure = M;
  177.   time1->MPart = P;
  178. }
  179.  
  180.  
  181. /********************************************************/
  182. /* Void DisplayLicense(ProgName)
  183. char *ProgName;*/
  184. void DisplayLicense()
  185. {
  186.   /********************************************************/
  187.   FILE *f;
  188.   /* long T; */
  189. #ifdef __TURBOC__
  190.   struct ftime T;
  191. #endif
  192.   /* DateTime DT;   defined in DOS unit */
  193.  
  194.   f = NULL;
  195.   printf("********************************************************\n");
  196.   printf("*        Midi2TeX translator %s           *\n",VERSION);
  197.   printf("*      authors:  H.J.P. Kuykens, A.H. Verbruggen       *\n");
  198.   printf("********************************************************\n");
  199.   if (f != NULL)
  200.     fclose(f);
  201. }
  202.  
  203.  
  204. /**************************************************/
  205. boolean FileExists(Filename)
  206. Char *Filename;
  207. {
  208.   /**************************************************/
  209.   boolean Result;
  210.   FILE *f;
  211.  
  212.   f = NULL;
  213.   f=fopen(Filename,"r");
  214.   Result = (f != NULL)&&(*Filename != '\0');
  215.   if (f != NULL) {fclose(f);}
  216.   f = NULL;
  217.   return Result;
  218. }  /* FileExists*/
  219.  
  220. unsigned int Probeer(getal)
  221. unsigned int getal;
  222. { return getal;
  223. }
  224. void _TP_Misc_init()
  225. {
  226.   static int _was_initialized = 0;
  227.   if (_was_initialized++)
  228.     return;
  229. }
  230.